<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <div>
      <div>
        <ul id="nav">
          <li>
            <ul>
              <li>ssss</li>
              <li>ssss</li>
              <li>ssss</li>
              <li class="abc">ssss</li>
            </ul>
          </li>
          <li>aaa</li>
          <li>aaa</li>
          <li>aaa</li>
          <li>aaa</li>
          <li>aaa</li>
        </ul>
      </div>
    </div>
  </div>


  <script src="./jquery-3.6.0.js"></script>
  <script>
    // console.log($('#nav').children()) // 只查找子元素
    // console.log($('#nav').find('li')) // 查找后代元素

    // console.log($('.abc').parent()); // 只找到父元素
    console.log($('.abc').parents('div')); // 找到祖先级元素，找到的是距离当前元素最近的那个div
  </script>

</body>

</html>